﻿
namespace Microsoft.Dynamics.AX.Framework.TeamFoundationServerFacade
{
    using System;
    using System.Collections.Generic;
    using Microsoft.TeamFoundation.WorkItemTracking.Client;

    /// <summary>
    /// A proxy class for WorkItem
    /// </summary>
    [Serializable]
    public class WorkItemProxy
    {
        /// <summary>
        /// Work item Title
        /// </summary>
        public string Title
        {
            get
            {
                return this.TfsWorkItem.Title;
            }
        }

        /// <summary>
        /// Work item Id
        /// </summary>
        public int Id
        {
            get
            {
                return this.TfsWorkItem.Id;
            }
        }

        internal WorkItem TfsWorkItem
        {
            get;
            private set;
        }
        
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="workItem">WorkItem to be proxed</param>
        internal WorkItemProxy(WorkItem workItem)
        {
            this.TfsWorkItem = workItem;
        }
    }

    /// <summary>
    /// A list of WorkItemProxy object
    /// </summary>
    [Serializable]
    public class WorkItemProxyCollection : List<WorkItemProxy>
    {
        /// <summary>
        /// Gets a Work Item by ID
        /// </summary>
        /// <param name="id">The id of the work item</param>
        /// <returns></returns>
        public WorkItemProxy GetById(int id)
        {
            return Find(tfsWorkItemList => tfsWorkItemList.Id == id);
        }
    }
}
